package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.WmSensitiveExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author jay
 * @date 2022/11/17 16:15:30
 */
@RestController
@RequestMapping("/api/v1/excel")
public class WmSensitiveExcelController {

    @Autowired
    private WmSensitiveExcelService wmSensitiveExcelService;

    @GetMapping("/download")
    public void download(HttpServletResponse response){
        wmSensitiveExcelService.downloadAsExcel(response);
    }

    @PostMapping("/upload")
    public ResponseResult upload(HttpServletRequest request, @RequestBody MultipartFile file){
        return wmSensitiveExcelService.addSensitiveFromExcelFile(file);
    }
}
